const Sequelize = require('sequelize');
const sequelize = require('../libs/sequelize')

const Artist = require('./artist')
const Album = require('./album')

const Music = sequelize.define('music', {
    id: {
        type: Sequelize.INTEGER,
        allowNull: true,
        primaryKey: true,
        autoIncrement: true
    },
    name: {
        type: Sequelize.STRING
    },
    duration: {
        type: Sequelize.FLOAT,
    },
    music: {
        type: Sequelize.STRING,
    },
    poster: {
        type: Sequelize.STRING
    },
    lyric: {
        type: Sequelize.STRING
    },
    playCount: {
        type: Sequelize.FLOAT,
    },
    artistId: {
        type: Sequelize.INTEGER
    },
    albumId: {
        type: Sequelize.INTEGER
    }
});

// force: true 如果表已经存在，将会丢弃表
// Music.sync({ force: true }).then(() => {

//     console.log('done ')

// });

Music.belongsTo(Artist)
Music.belongsTo(Album)


module.exports = Music